#!/bin/bash

convertF () {
x=$((612*2)); 
y=$((792*2)); 
convert -size ${x}x${y} xc:white \
    $1 \
    -fill white \
    -density 72 \
    -gravity Center \
    -resize ${x}x${y}+$(($x/2))+$((y/2)) \
    -composite `basename $1`;
}

for i in $1/*.jpg ; do 
    echo $i
    convertF $i; 
done

convert -page Letter *.jpg -compress jpeg $2
